      1  import java.io.File;

      2  import java.io.FileInputStream;

      3  import java.io.FileOutputStream;

      4  import java.io.InputStream;

      5  import java.io.IOException;

      6  import java.io.OutputStream;

      7  import java.util.Scanner;

      8

      9  /**

     10     This program encrypts a file, using the Caesar cipher.

     11  */

     12  public class CaesarEncryptor

     13  {

     14     public static void main(String[] args)

     15     {

     16        Scanner in = new Scanner(System.in);

     17        try

     18        {

     19           System.out.print("Input file: ");

     20           String inFile = in.next();

     21           System.out.print("Output file: ");

     22           String outFile = in.next();

     23           System.out.print("Encryption key: ");

     24           int key = in.nextInt();

     25

     26           InputStream inStream = new FileInputStream(inFile);

     27           OutputStream outStream = new FileOutputStream(outFile);

     28

     29           CaesarCipher cipher = new CaesarCipher(key);

     30           cipher.encryptStream(inStream, outStream);

     31

     32           inStream.close();

     33           outStream.close();

     34        }

     35        catch (IOException exception)

     36        {

     37           System.out.println("Error processing file: " + exception);

     38        }

     39     }

     40  }

     41

     42